package luminus.origin.commands

import org.bukkit.entity.Player
import taboolib.common.LifeCycle
import taboolib.common.platform.Awake
import taboolib.common.platform.command.PermissionDefault
import taboolib.common.platform.command.simpleCommand
import taboolib.module.lang.sendLang
import taboolib.platform.util.sendLang

object Fly {
    @Awake(LifeCycle.ENABLE)
    fun init() {
        simpleCommand("fly", permission = "luminus.command.fly", permissionDefault = PermissionDefault.OP) { sender, _ ->
            val pl = sender.castSafely<Player>()
            if (pl == null){
                sender.sendLang("commands-fly-unknownPlayer")
            } else {
                pl.allowFlight = !pl.allowFlight
                pl.sendLang("commands-fly-okay")
            }
        }

    }
}